package com.zw.demo01.common.datasource;

import java.util.List;

/**
 * @ClassName: DataSourceContextHolder
 * @Description TODO
 * @Author: zzw
 * @Date: 2023/3/28 11:25
 * @Version 1.0.0
 */
public class DataSourceContextHolder {

    private static  List<Object> DBTypes;
    private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();
    //设置当前线程持有的数据源
    public static synchronized void setDBType(String dbType){
        contextHolder.set(dbType);
    }
    //获取当前线程持有的数据源
    public static String getDBType(){
        return contextHolder.get();
    }

    public static List<Object> getDBTypes(){
        return DBTypes;
    }
    public static void clearDBType(){
        contextHolder.remove();
    }
}
